package com.vita.testCore.put;

import com.vita.testCore.CvtExecute1;
import com.vita.testCore.CvtStep;
import com.vita.testCore.CvtExecute;
import com.vita.testCore.func.CvtExecuteInOut;
import com.vita.testCore.value.Entry;

import java.util.Objects;

/**
 * InOut （对象操作符）：
 * 输入输出会被放入一个Entry
 */
public class InOut<I,O> implements CvtStep {
    private I input;
    private O output;

    public InOut(I i,O o) {
        this.input = i;
        this.output = o;
    }

//    @Override
    public void plan(CvtExecute execute) {
        Objects.requireNonNull(execute, "请构建执行器TaskExecute");
        if(!(execute instanceof CvtExecuteInOut)){
            throw new ClassCastException("InOut<I,O> 必须使用 CvtExecuteFunc2 执行器");
        }
        CvtExecuteInOut ce = (CvtExecuteInOut) execute;
        ce.input(new Entry<I,O>(input,output));
        ce.run(input,output);
    }

    @Override
    public void plan(CvtExecute1 execute) {

    }
}
